/**
 * Created by wsx on 2017/1/17.
 */
$(function(){
        var uemailflag = false;
        var upasswdflag = false;
        $('#uemail').blur(function () {
            if("" == $(this).val()){
                $('#dis_info').text("");
                uemailflag = false;
                $('#dis_uemail').text("请输入邮箱！！");
            }else{
                $('#dis_info').text("");
                uemailflag = true;
                $('#dis_uemail').text("");
            }
        });
        $('#upasswd').blur(function () {
            if("" == $(this).val()){
                $('#dis_info').text("");
                upasswdflag = false;
                $('#dis_upasswd').text("请输入密码！！");
            }else{
                $('#dis_info').text("");
                upasswdflag = true;
                $('#dis_upasswd').text("");
            }
        });
    $('#login').click(function () {
         if((!uemailflag)||(!upasswdflag))
             return;
         $.ajax({
             type: "POST",
             url: "/login",
             data: {
                 uemail: $('#uemail').val(),
                 upasswd: $('#upasswd').val()
             },
             dataType :"text",
             success: function (data) {
                 if("true" == data) {
                     location.href = "/";
                 }else{
                     $('#dis_info').text("用户名或密码错误");
                 }
             }
         });
    });
});